﻿using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Markup;

namespace WgpgGUI
{
    public class CustomMessageBoxMessageConverter : IValueConverter
    {
        public Object Convert(Object value, Type targetType, Object parameter, CultureInfo culture)
        {
            String formatString = value.ToString();
            formatString = formatString.Replace("\n", "<LineBreak/>");
            formatString = "<TextBlock xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" Foreground=\"Black\" TextWrapping=\"Wrap\">" + formatString + "</TextBlock>";

            return XamlReader.Parse(formatString);
        }

        public Object ConvertBack(Object value, Type targetType, Object parameter, CultureInfo culture)
        {
            throw new NotSupportedException("The CustomMessageBoxMessageConverter.ConvertBack method is not supported.");
        }
    }
}
